<template>
    <div>
        <Card>
            <Row class="form-row">
                <Form :model="filtersOne" ref="form1" label-position="right" :label-width="90" inline>
                    <FormItem label="小区名称" prop="name">
                        <div class="filters-input">
                            <el-select v-model="filtersOne.housingId" filterable default-first-option
                                       placeholder="请选择小区" :clearable="true"
                                       @change="onehousechange" no-data-text="暂无数据">
                                <el-option v-for="item in houseList" :key="item.id" :label="item.name" :value="item.id">
                                </el-option>
                            </el-select>
                        </div>
                    </FormItem>
                    <FormItem label="组团" prop="groupName">
                        <div class="filters-input">
                            <el-select v-model="filtersOne.groupName" filterable default-first-option
                                       placeholder="请选择组团" :clearable="true"
                                       no-data-text="暂无数据" @change="filterOnegroupNamechange">
                                <el-option v-for="item in filtergroupList" :key="item.label" :label="item.label"
                                           :value="item.label">
                                </el-option>
                            </el-select>
                        </div>
                    </FormItem>
                    <FormItem label="楼栋" prop="building">
                        <div class="filters-input">
                            <el-select v-model="filtersOne.building" filterable default-first-option placeholder="请选择楼栋"
                                       :clearable="true"
                                       no-data-text="暂无数据" @change="filterOnebuildingchange">
                                <el-option v-for="item in filterbuildList" :key="item.label" :label="item.label"
                                           :value="item.label">
                                </el-option>
                            </el-select>
                        </div>
                    </FormItem>
                    <FormItem label="单元" prop="unit">
                        <div class="filters-input">
                            <el-select v-model="filtersOne.unit" filterable default-first-option placeholder="请选择单元"
                                       :clearable="true"
                                       no-data-text="暂无数据" @change="filterOneunitchange">
                                <el-option v-for="item in filterunitList" :key="item.label" :label="item.label"
                                           :value="item.label">
                                </el-option>
                            </el-select>
                        </div>
                    </FormItem>
                    <FormItem label="房间号" prop="room">
                        <div class="filters-input">
                            <el-select v-model="filters_room" no-data-text="暂无数据" filterable default-first-option
                                       :clearable="true"
                                       placeholder="请选择房间号">
                                <el-option v-for="item in filterroomList" :key="item.label" :label="item.label"
                                           :value="item.label">
                                </el-option>
                            </el-select>
                        </div>
                    </FormItem>

                    <FormItem label="业主姓名" prop="name">
                        <div class="filters-input">
                            <Input v-model="filtersOne.name" placeholder="业主姓名"/>
                        </div>
                    </FormItem>

                    <FormItem label="认证状态" prop="hainaStatus">
                        <div class="filters-input">
                            <el-select v-model="hainaStatus" no-data-text="暂无数据" placeholder="请选择认证状态"
                                       :clearable="true">
                                <el-option v-for="item in statusList" :key="item.label" :label="item.label"
                                           :value="item.value">
                                </el-option>
                            </el-select>
                        </div>
                    </FormItem>

                    <FormItem>
                        <Button type="primary" icon="ios-search" @click="handleQuery('form1')">
                            搜索
                        </Button>
                    </FormItem>
                </Form>

            </Row>
            <Row class="form-row">
                <Button type="primary" icon="md-add" @click="handleAdd()" style="margin-right: 10px;">新增</Button>
                <Button type="primary" icon="md-trash" @click="delOwnerAll()" style="margin-right: 10px;">批量删除</Button>
                <Button type="warning" icon="md-share-alt" @click="exportExcel" style="margin-right: 10px;">导出为Excel文件
                </Button>
                <!--<Button type="warning" icon="md-sync" @click="moreToHaiNa" style="margin-right: 10px;">批量获取认证的海纳用户bf</Button>-->
                <Button type="warning" icon="md-sync" @click="moreGetHaiNa" style="margin-right: 10px;">批量获取认证的海纳用户
                </Button>
            </Row>

            <el-table stripe border :loading="tableLoading" :data="tableData" ref="table" style="width: 100%">
                <template slot="empty">暂无数据</template>
                <el-table-column label="小区名称">
                    <template slot-scope="scope">
                        {{scope.row.houseName}}
                    </template>
                </el-table-column>
                <el-table-column prop="groupName" label="组团"></el-table-column>
                <el-table-column prop="building" label="楼栋"></el-table-column>
                <el-table-column prop="unit" label="单元"></el-table-column>
                <el-table-column prop="room" label="房间"></el-table-column>
                <el-table-column prop="name" label="业主姓名"></el-table-column>
                <el-table-column prop="sex" label="性别" :formatter="sexType"></el-table-column>
                <el-table-column prop="phone" label="联系电话"></el-table-column>
                <!--<el-table-column prop="card" label="证件号"></el-table-column>
                <el-table-column prop="job" label="工作单位"></el-table-column>-->
                <el-table-column prop="hainaStatus" label="认证状态" :formatter="attestStatus"></el-table-column>
                <el-table-column prop="typeInt" label="身份状态" :formatter="typeStatus"></el-table-column>
                <el-table-column label="操作" width="150" align="center">
                    <template slot-scope="scope">
                        <el-button size="mini" type="primary" @click="handleAdd( scope.row.id)">修改</el-button>
                        <el-button size="mini" type="danger" @click="handleDelete( scope.row.id)">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>

            <Page style="margin: 10px 0;" :total="pageTotal" :current="pageNum" :page-size="pageSize" show-total
                  show-sizer show-elevator @on-change="handlePage" @on-page-size-change='handlePageSize'>
            </Page>
        </Card>

        <Modal v-model="modal2" title="导出文件" class="modal-content">
            <Form :model="fileoutmodal" :rules="rule" ref="fileoutform" label-position="right" :label-width="100"
                  class="myOpenFrom">
                <FormItem label="小区" prop="housename">
                    <Select v-model="fileoutmodal.housename" placeholder="请选择小区" style="width:100%" filterable
                            :clearable="true">
                        <Option v-for="item in houseList" :value="item.id" :key="item.id">{{ item.name }}</Option>
                    </Select>
                </FormItem>
            </Form>
            <div slot="footer">
                <Button type="text" @click="onCancel">取消</Button>
                <Button type="primary" @click="fileoutSubmit" :loading="formLoading">确定导出</Button>
            </div>
        </Modal>

        <Modal v-model="modal3" title="同步到海纳" class="modal-content">
            <Form :model="toHainaModal" :rules="rule" ref="fileoutform" label-position="right" :label-width="100"
                  class="myOpenFrom">
                <FormItem label="小区" prop="housename">
                    <Select v-model="toHainaModal.housename" placeholder="请选择小区" style="width:100%" filterable
                            :clearable="true">
                        <Option v-for="item in houseList" :value="item.id" :key="item.id">{{ item.name }}</Option>
                    </Select>
                </FormItem>
            </Form>
            <div slot="footer">
                <Button type="text" @click="onCancel">取消</Button>
                <Button type="primary" @click="hainaSubmit" :loading="formLoading">确定同步</Button>
            </div>
        </Modal>


        <Modal v-model="formVisible" :title="modal && modal.id ? '修改' : '新增'" class="modal-content" width="900">
            <Form :model="filters" :rules="rule" ref="form3" label-position="right" :label-width="110"
                  class="myOpenFrom">
                <FormItem label="小区名称" prop="housingId">
                    <el-select v-model="filters.housingId" filterable default-first-option placeholder="请选择小区"
                               :clearable="true"
                               style="width:100%" @change="housechange" no-data-text="暂无数据">
                        <el-option v-for="item in houseList" :key="item.id" :label="item.name" :value="item.id">
                        </el-option>
                    </el-select>
                </FormItem>
                <FormItem label="组团" prop="groupName">
                    <el-select v-model="filters.groupName" filterable default-first-option placeholder="请选择组团"
                               :clearable="true"
                               style="width:100%" no-data-text="暂无数据" @change="filtergroupNamechange">
                        <el-option v-for="item in filtergroupList" :key="item.label" :label="item.label"
                                   :value="item.label">
                        </el-option>
                    </el-select>
                </FormItem>
                <FormItem label="楼栋" prop="building">
                    <el-select v-model="filters.building" filterable default-first-option placeholder="请选择楼栋"
                               :clearable="true"
                               style="width:100%" no-data-text="暂无数据" @change="filterbuildingchange">
                        <el-option v-for="item in filterbuildList" :key="item.label" :label="item.label"
                                   :value="item.label">
                        </el-option>
                    </el-select>
                </FormItem>
                <FormItem label="单元" prop="unit">
                    <el-select v-model="filters.unit" filterable default-first-option placeholder="请选择单元"
                               :clearable="true"
                               style="width:100%" no-data-text="暂无数据" @change="filterunitchange">
                        <el-option v-for="item in filterunitList" :key="item.label" :label="item.label"
                                   :value="item.label">
                        </el-option>
                    </el-select>
                </FormItem>

                <FormItem label="房间号">
                    <Select v-model="filters_room" no-data-text="暂无数据" filterable default-first-option
                            placeholder="请选择房间号" style="width:100%" :clearable="true">
                        <Option v-for="item in filterroomList" :key="item.label" :label="item.label"
                                :value="item.label">
                        </Option>
                    </Select>
                </FormItem>
                <FormItem label="业主姓名" prop="name">
                    <Input v-model="filters.name" placeholder="业主姓名"/>
                </FormItem>
                <FormItem label="性别" prop="sex">
                    <RadioGroup v-model="filters.sex">
                        <Radio label="2">女</Radio>
                        <Radio label="1">男</Radio>
                    </RadioGroup>
                </FormItem>
                <FormItem label="身份证号码">
                    <Input v-model="filters.card" placeholder="身份证号码"/>
                </FormItem>
                <FormItem label="联系电话" prop="phone">
                    <Input v-model="filters.phone" placeholder="联系电话"/>
                </FormItem>
                <FormItem label="身份状态" prop="typeInt">
                    <RadioGroup v-model="filters.typeInt" @on-change="typeIntchange">
                        <Radio label="1">业主</Radio>
                        <Radio label="2">家属</Radio>
                        <Radio label="3">短期租客</Radio>
                        <Radio label="4">长期租客</Radio>
                    </RadioGroup>
                </FormItem>
                <FormItem label="租约到期时间" v-show="houseshow==3 ? true : false" prop="expireTime">
                    <DatePicker type="date" format="yyyy-MM-dd" v-model="filters.expireTime"
                                style="width: 100%"></DatePicker>
                </FormItem>

                <FormItem label="工作单位" prop="job">
                    <Input v-model="filters.job" placeholder="工作单位"/>
                </FormItem>
                <FormItem label="爱好" prop="hobby">
                    <Input v-model="filters.hobby" placeholder="爱好"/>
                </FormItem>
                <FormItem label="婚姻状况" prop="marriage">
                    <RadioGroup v-model="filters.marriage">
                        <Radio label="2">未婚</Radio>
                        <Radio label="1">已婚</Radio>
                    </RadioGroup>
                </FormItem>
                <FormItem label="文化程度" prop="culture">
                    <Input v-model="filters.culture" placeholder="文化程度"/>
                </FormItem>
                <FormItem label="备注" prop="remark">
                    <Input v-model="filters.remark" type="textarea" :autosize="{minRows: 2,maxRows: 5}"
                           placeholder="备注"></Input>
                </FormItem>

            </Form>

            <div slot="footer">
                <Button type="text" size="large" @click="onCancel">取消</Button>
                <Button type="primary" size="large" @click="handleSubmit" :loading="formLoading">确定</Button>
            </div>

        </Modal>

        <Modal v-model="DelModal" title="批量删除" class="modal-content" :mask-closable="false">
            <Form :model="delOwner" :rules="rule" ref="delForm" label-position="right" :label-width="140" inline>
                <FormItem label="小区" prop="housingId">
                    <el-select v-model="delOwner.housingId" filterable placeholder="请选择小区"
                               :clearable="true" no-data-text="暂无数据">
                        <el-option v-for="item in houseList" :key="item.id" :label="item.name"
                                   :value="item.id"></el-option>
                    </el-select>
                </FormItem>
                <FormItem label="同步状态" prop="hainaStatus">
                    <el-select v-model="delOwner.hainaStatus" no-data-text="暂无数据" placeholder="请选择同步状态"
                               :clearable="true">
                        <el-option value="-1" label="未同步"></el-option>
                        <el-option value="1" label="已同步"></el-option>
                    </el-select>
                </FormItem>
            </Form>
            <div slot="footer">
                <Button type="text" @click="onCancel">取消</Button>
                <Button type="primary" @click="submitDel" :loading="formLoading">确定</Button>
            </div>
        </Modal>

        <Modal v-model="loadMode" title="同步海纳" width="450" class="modal-content" :mask-closable="false">
            <div class="moneybox tips">
                <Icon type="ios-information-circle-outline" color="red" size="16px"/>
                <span>关闭弹窗不影响同步</span>
            </div>
            <div class="info" v-loading="loadingInfo"></div>
            <p class="p-info">正在同步{{msgInfo.housingName||'--'}}信息（{{msgInfo.son ||'--'}}/{{msgInfo.total
                ||'--'}}），请稍等...</p>
            <div slot="footer">
                <Button type="primary" @click="btnSure">确定</Button>
            </div>
        </Modal>


        <!--批量获取认证的海纳用户af-->
        <Modal v-model="getModeHaiNa" title="获取认证海纳用户" width="600" class="modal-content" :mask-closable="false">
            <div class="loadWrap" style="width: 100%;height: 80px;" v-loading="loadWrap"
                 element-loading-text="获取认证海纳用户中"
                 element-loading-spinner="el-icon-loading">
                <Form :model="getHaiNaMore" :rules="rule" ref="getHaiNaMore" label-position="right" :label-width="100"
                      class="myOpenFrom">
                    <FormItem label="小区" prop="housingId">
                        <Select v-model="getHaiNaMore.housingId" placeholder="请选择小区" style="width:100%" filterable
                                :clearable="true">
                            <Option v-for="item in houseList" :value="item.id" :key="item.id">{{ item.name }}</Option>
                        </Select>
                    </FormItem>
                </Form>
            </div>

            <div slot="footer">
                <Button type="text" @click="getModeHaiNa=false;">取消</Button>
                <Button type="primary" @click="sureGetHaiNa()" :loading="formLoading">确定获取</Button>
            </div>
        </Modal>


    </div>
</template>
<script>
    import baseURL from '_conf/url'
    import Treeselect from "@riophae/vue-treeselect";
    import Cookies from 'js-cookie'
    import {TOKEN_KEY} from '@/libs/util'

    const token = Cookies.get(TOKEN_KEY)

    const act = baseURL + "/api/owner/upload"

    //校验规则
    const rules = {
        parentId: [
            {
                required: true,
                message: "请选择物业",
                trigger: "blur"
            }
        ],
        // sex: [{
        //     required: true,
        //     message: "请选择性别",
        //     transfer: "blur"
        // }],
        phone: [{
            required: true,
            message: "请输入联系电话",
            transfer: "blur"
        }
        ],
        housingId: [{
            required: true,
            message: "请选择小区"
        }],
        filters_room: [{
            required: true,
            message: "请选择房间号"
        }],
        housename: [{
            required: true,
            message: "请选择小区"
        }],
        name: [{
            required: true,
            message: "请填写业主名称",
            trigger: "change"
        }],

    };
    export default {
        name: "userList",
        components: {
            Treeselect
        },
        data() {
            return {
                statusList: [
                    {
                        value: 1,
                        label: '已认证'
                    },
                    {
                        value: -1,
                        label: '未认证'
                    }
                ],
                data1: {},
                houseshow: 0,
                groupList: [],//组团
                buildingList: [],//楼栋
                unitList: [],//单元
                houseL: null,//小区id
                modal1: false,
                fileList: [],
                modal2: false,
                modal3: false,
                hainaModal: false,
                file: null,
                act: act,
                loadingStatus: false,
                housingId: null,
                houseList: [],//小区
                modalhouseList: [],
                name: "",
                hainaStatus: "",
                deptList: [],
                //查询条件
                filters: {sex: '2', typeInt: '1', marriage: 'false'},
                filtersOne: {},
                //页码
                pageNum: 1,
                //每页数量
                pageSize: 10,
                //总数
                pageTotal: 0,
                //验证规则
                rule: rules,
                token: token,
                //选择上级机构
                optionsDepart: [],

                //表格数据
                tableData: [],
                tableData1: [],
                //数据表格隐藏那个状态
                tableLoading: false,
                //对话框隐藏状态
                formVisible: false,
                formPrintVisible: false,
                hainaModal: false,
                //表单提交状态
                formLoading: false,
                modal: {},
                DelModal: false,
                delOwner: {
                    housingId: '',
                },
                filemodal: {},//文件导入
                fileoutmodal: {},//文件导出
                toHainaModal: {},//文件导出
                haina: {},
                casdata: [],
                housedata: [],
                value3: [],
                //filter里面的
                filtergroupList: [],
                filterbuildList: [],
                filterunitList: [],
                filterroomList: [],
                filters_room: '',
                timer: null,
                msgInfo: '',
                loadMode: false,
                loadingInfo: false,
                getModeHaiNa: false,
                getHaiNaMore: {},
                loadWrap: false,
            };
        },
        created: function () {
            this.gethouse();
        },
        methods: {
            //表格显示性别
            sexType(row, column) {
                if (row.sex == 1) {
                    return "男";
                } else if (row.sex == 2) {
                    return "女"
                } else {
                    return "未知"
                }
            },
            //表格显示海纳认证状态
            attestStatus(row, column) {
                if (row.hainaStatus == 1) {
                    return "已认证";
                } else {
                    return "未认证"
                }
            },
            //表格显示身份状态
            typeStatus(row, column) {
                if (row.typeInt == 1) {
                    return "业主";
                } else if (row.typeInt == 2) {
                    return "家属";
                } else if (row.typeInt == 3) {
                    return "租客";
                }
            },
            //加载小区
            gethouse() {
                let url = "/api/housing/getHousingByLogin";
                this.postRequest(url).then(res => {
                    this.houseList = res;
                    this.modalhouseList = res;
                    this.filtersOne.housingId = res[0].id;
                    this.delOwner.housingId = res[0].id;
                    this.housechange(this.filtersOne.housingId);
                    this.loadData();
                });
            },
            //新增修改、选择小区加载组团
            housechange(value) {
                console.log("选中了" + value);
                if (value) {
                    this.filtergroupList = [];
                    this.filterbuildList = [];
                    this.filterunitList = [];
                    this.filterroomList = [];
                    this.filters.groupName = '';
                    this.filters.building = '';
                    this.filters.unit = '';
                    this.filters_room = '';
                    this.getRequest("/api/room/queryGroupName?housingId=" + value).then(res => {
                        console.log(res)
                        if (res.data.groupList != null) {
                            this.filtergroupList = res.data.groupList;
                        } else if (res.data.buildList != null) {
                            this.filterbuildList = res.data.buildList;
                        } else if (res.data.unitList != null) {
                            this.filterunitList = res.data.unitList;
                        } else {
                            this.filterroomList = res.data.roomList;
                        }
                    });
                }
            },
            //新增修改、选择组团加载楼栋
            filtergroupNamechange(value) {
                console.log("选中了" + value);
                if (value) {
                    this.filterbuildList = [];
                    this.filterunitList = [];
                    this.filterroomList = [];
                    this.filters.building = '';
                    this.filters.unit = '';
                    this.filters_room = '';
                    this.getRequest("/api/room/queryBuilding?groupName=" + value + "&housingId=" + this.filters.housingId).then(res => {
                        if (res.data.buildList) {
                            this.filterbuildList = res.data.buildList;
                        } else if (res.data.unitList != null) {
                            this.filterunitList = res.data.unitList;
                        } else {
                            this.filterroomList = res.data.roomList;
                        }
                    });
                }
            },
            //新增修改、选择楼栋加载单元
            filterbuildingchange(value) {
                console.log("组团是" + value);
                if (value) {
                    this.filterunitList = [];
                    this.filterroomList = [];
                    this.filters.unit = '';
                    this.filters_room = '';
                    this.getRequest("/api/room/queryUnit?building=" + value + "&housingId=" + this.filters.housingId + "&groupName=" + this.filters.groupName).then(res => {
                        console.log(res)
                        if (res.data.unitList != null) {
                            this.filterunitList = res.data.unitList;
                        } else {
                            this.filterroomList = res.data.roomList;
                        }
                    });
                }
            },
            //新增修改、选择单元加载房间
            filterunitchange(value) {
                console.log("选中了" + value);
                if (value) {
                    this.filterroomList = [];
                    this.filters_room = '';
                    this.getRequest("/api/room/queryRoom?unit=" + value + "&housingId=" + this.filters.housingId + "&groupName=" + this.filters.groupName + "&building=" + this.filters.building).then(res => {
                        console.log(res)
                        this.filterroomList = res.data.roomList;
                    });
                }
            },
            //查询条件、选择小区加载组团
            onehousechange(value) {
                console.log("选中了" + value);
                if (value) {
                    this.filtergroupList = [];
                    this.filterbuildList = [];
                    this.filterunitList = [];
                    this.filterroomList = [];
                    this.filtersOne.groupName = '';
                    this.filtersOne.building = '';
                    this.filtersOne.unit = '';
                    this.filters_room = '';
                    this.getRequest("/api/room/queryGroupName?housingId=" + value).then(res => {
                        console.log(res)
                        if (res.data.groupList != null) {
                            this.filtergroupList = res.data.groupList;
                        } else if (res.data.buildList != null) {
                            this.filterbuildList = res.data.buildList;
                        } else if (res.data.unitList != null) {
                            this.filterunitList = res.data.unitList;
                        } else {
                            this.filterroomList = res.data.roomList;
                        }
                    });
                }
            },
            //查询条件、选择组团加载楼栋
            filterOnegroupNamechange(value) {
                if (value) {
                    this.filterbuildList = [];
                    this.filterunitList = [];
                    this.filterroomList = [];
                    this.filters.building = '';
                    this.filters.unit = '';
                    this.filters_room = '';
                    this.getRequest("/api/room/queryBuilding?groupName=" + value + "&housingId=" + this.filtersOne.housingId).then(res => {
                        console.log(res)
                        if (res.data.buildList != null) {
                            this.filterbuildList = res.data.buildList;
                        } else if (res.data.unitList != null) {
                            this.filterunitList = res.data.unitList;
                        } else {
                            this.filterroomList = res.data.roomList;
                        }
                    });
                }
            },
            //查询条件、选择楼栋加载单元
            filterOnebuildingchange(value) {
                if (value) {
                    this.filterunitList = [];
                    this.filterroomList = [];
                    this.filters.unit = '';
                    this.filters_room = '';
                    this.getRequest("/api/room/queryUnit?building=" + value + "&housingId=" + this.filtersOne.housingId + "&groupName=" + this.filtersOne.groupName).then(res => {
                        console.log(res)
                        if (res.data.unitList != null) {
                            this.filterunitList = res.data.unitList;
                        } else {
                            this.filterroomList = res.data.roomList;
                        }
                    });
                }
            },
            //查询条件、选择单元加载房间
            filterOneunitchange(value) {
                console.log("选中了" + value);
                if (value) {
                    this.filterroomList = [];
                    this.filters_room = '';
                    this.getRequest("/api/room/queryRoom?unit=" + value + "&housingId=" + this.filtersOne.housingId + "&groupName=" + this.filtersOne.groupName + "&building=" + this.filtersOne.building).then(res => {
                        console.log(res)
                        this.filterroomList = res.data.roomList;
                    });
                }
            },
            //打开导出表格页面
            exportExcel() {
                this.modal2 = true;
            },
            //文件导出确定按钮
            fileoutSubmit() {
                window.location.href = baseURL + "/common/getOwnerExcel?housingId=" + this.fileoutmodal.housename;
                this.formLoading = true;
                this.modal2 = false;
                this.$refs["fileoutform"].resetFields();

            },
            //批量同步海纳
            moreToHaiNa() {
                this.postRequest("/common/checkImport?lockStatus=haina").then(res => {
                    if (res.code == 20000) {
                        this.loadMode = true;
                        this.loadingInfo = true;
                        this.timer = setInterval(() => {
                            this.postRequest("/common/checkImport?lockStatus=haina").then(res => {
                                console.log(res);
                                if (res.code == 20000) {
                                    this.msgInfo = res.data;
                                }
                            });
                        }, 2000)
                    } else {
                        this.modal3 = true;
                    }
                });
            },
            //批量获取认证的海纳用户 af
            moreGetHaiNa: function () {
                this.getModeHaiNa = true;
            },

            // 确认批量获取按钮 af
            sureGetHaiNa: function () {
                this.$refs["getHaiNaMore"].validate(valid => {
                    if (valid) {
                        this.formLoading = true;
                        this.loadWrap = true;
                        const housingId = this.getHaiNaMore.housingId;
                        this.postRequest("/api/owner/getHainaUserinfo?housingId=" + housingId,).then(res => {
                            this.formLoading = false;
                            this.loadWrap = false;
                            this.getModeHaiNa = false;
                            if (res.code == 20000) {
                                this.$notify.success({
                                    title: "批量获取海纳认证用户",
                                    message: res.message,
                                    duration: 0
                                });
                            } else {
                                this.formLoading = false;
                                this.loadWrap = false;
                                this.getModeHaiNa = false;
                                this.$notify.error({
                                    title: "批量获取海纳认证用户",
                                    message: res.message,
                                    duration: 0
                                });
                            }
                        });
                    }
                });
            },

            //同步到海纳确定按钮
            hainaSubmit() {
                this.$refs["fileoutform"].validate(valid => {
                    if (valid) {
                        let housingId = this.toHainaModal.housename;
                        //打开loading模态框
                        this.modal3 = false;
                        this.loadingInfo = true;
                        this.loadMode = true;

                        this.postRequest("/api/owner/batchHaina?housingId=" + housingId,).then(res => {
                            if (res.code == 20000) {
                                clearInterval(this.timer)
                                this.postRequest("/common/clearImport?lockStatus=haina").then(res => {
                                    this.loadMode = false;
                                });
                                this.$notify.success({
                                    title: "同步到海纳>同步",
                                    message: res.message,
                                    duration: 0
                                });
                            } else {
                                clearInterval(this.timer)
                                this.postRequest("/common/clearImport?lockStatus=haina").then(res => {
                                    this.loadMode = false;
                                });
                                this.$notify.error({
                                    title: "同步到海纳>同步",
                                    message: res.message,
                                    duration: 0
                                });
                            }
                        });

                        this.timer = setInterval(() => {
                            this.postRequest("/common/checkImport?lockStatus=haina").then(res => {
                                console.log(res);
                                if (res.code == 20000) {
                                    this.msgInfo = res.data;
                                }
                            });
                        }, 2000)
                    }
                });
            },
            //新增修改、选择身份状态信息
            typeIntchange(value) {
                if (value == 3) {
                    this.houseshow = 3;
                } else {
                    this.houseshow = 0;
                    this.expireTime = "";
                }
            },
            //加载数据
            loadData() {
                if (this.tableLoading) return;
                this.tableLoading = true;
                let params = this.filtersOne;
                params.room = this.filters_room
                params.pageNum = this.pageNum;
                params.pageSize = this.pageSize;
                params.hainaStatus = this.hainaStatus;

                //与后台交换数据
                this.postRequest("/api/owner/loadData", params).then(res => {

                    console.log(params);
                    this.tableLoading = false;
                    if (res.code == 20000) {
                        this.tableData = res.data.list;
                        this.pageTotal = res.data.total;
                    } else {
                        this.tableData = [];
                        this.$Message.error({
                            content: res.message,
                            duration: 5
                        });
                    }
                });
            },
            //查询
            handleQuery(name) {
                this.filtersOne.pageNum = 1;
                this.loadData();
            },
            //打开新增修改页面
            handleAdd(id) {
                let url = "/api/owner/openModel";
                this.modal = {};
                if (id) {
                    url = "/api/owner/openModel?id=" + id;
                    this.getRequest(url).then(res => {
                        console.log(res)
                        this.tableLoading = false;
                        if (res.code == 20000) {
                            res.data.owner.sex = String(res.data.owner.sex);
                            res.data.owner.marriage = String(res.data.owner.marriage);
                            res.data.owner.typeInt = String(res.data.owner.typeInt);
                            this.filters = res.data.owner;
                            this.filters.building = res.data.room.building;
                            this.filters.unit = res.data.room.unit;
                            this.filters_room = res.data.room.room;
                            this.filters.groupName = res.data.room.groupName;
                            this.modal.housename = res.data.id;
                            this.formVisible = true;
                        } else {
                            this.$Message.error({
                                content: res.message,
                                duration: 5
                            });
                        }
                    });
                } else {
                    this.filters = {
                        sex: '2',
                        marriage: '2',
                        typeInt: '1'
                    };
                    this.formVisible = true;
                }
            },
            //新增修改保存按钮
            handleSubmit() {
                this.$refs["form3"].validate(valid => {
                    if (valid) {
                        this.formLoading = true;
                        this.save();
                    }
                });
            },
            //保存
            save() {
                this.filters.room = this.filters_room;
                if (this.filters.typeInt == 3) {
                    this.filters.expireTime = (this.filters.expireTime).toLocaleDateString();
                }
                this.postRequest("/api/owner/saveOrUpdate", this.filters).then(res => {
                    this.tableLoading = false;
                    if (res.code == 20000) {
                        this.formLoading = false;
                        this.formVisible = false;
                        this.$refs["form3"].resetFields();
                        this.filters_room = "";
                        this.loadData();
                        this.$Message.success("保存成功！");
                    } else {
                        this.formLoading = false;
                        this.$Message.error({
                            content: res.message,
                            duration: 5
                        });
                    }
                });
            },
            //删除
            handleDelete(id) {
                this.$Modal.confirm({
                    title: '提示',
                    content: '确定删除该条数据？',
                    onOk: () => {
                        this.getRequest("/api/owner/delOwner?id=" + id).then(res => {
                            this.tableLoading = false;
                            if (res.code == 20000) {
                                this.$Message.success("删除成功!");
                                this.pageNum = 1;
                                this.loadData();
                            } else {
                                this.$Message.error({
                                    content: res.message,
                                    duration: 5
                                });
                            }
                        });
                    },
                });
            },
            //打开批量删除条件页面
            delOwnerAll() {
                this.DelModal = true;
            },
            //确定批量删除
            submitDel() {
                this.$refs["delForm"].validate(valid => {
                    if (valid) {
                        this.DelModal = false;
                        this.postRequest("/api/owner/delOwnerAll", this.delOwner).then(res => {
                            if (res.code == 20000) {
                                this.$Message.success("删除成功!");
                                this.pageNum = 1;
                                this.loadData();
                            }
                        });
                    }
                });
            },
            //取消按钮
            onCancel() {
                this.$refs["form1"].resetFields();
                this.$refs["form3"].resetFields();
                this.formPrintVisible = false;
                this.formLoading = false;
                this.formVisible = false;
                this.modal1 = false;
                this.modal2 = false;
                this.modal3 = false;
                this.hainaModal = false;
                this.DelModal = false;
            },
            handlePage(value) {
                this.pageNum = value;
                this.loadData();
            },
            handlePageSize(value) {
                this.pageSize = value;
                this.loadData();
            },
            //    确认导入进度框
            btnSure: function () {
                clearInterval(this.timer);
                this.msgInfo = {},
                    this.loadingInfo = false;
                this.loadMode = false;
            }

        },
        destroyed() {
            clearInterval(this.timer);
        },
    };


</script>

<style lang="less" scoped>
    .moneybox {
        font-szie: 16px;
        background: #f0faff;
        border: 1px solid #abdcff;
        border-radius: 4px;
        padding: 8px 48px 8px 8px;
        margin-bottom: 10px;
        span {
            padding-left: 10px;
        }
        em {
            color: red;
            font-style: normal;
        }
    }

    .info {
        width: 100px;
        height: 100px;
        margin: 0 auto;
    }

    .p-info {
        text-align: center;
        font-size: 14px;
        line-height: 40px;
    }

</style>
